﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace MyDatabase
{
    public partial class MyMVCContext : DbContext
    {
        public MyMVCContext()
        {
        }

        public MyMVCContext(DbContextOptions<MyMVCContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Good> Goods { get; set; }
        public virtual DbSet<User> Users { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=MyMVC;Integrated Security=True");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<Good>(entity =>
            {
                entity.ToTable("good");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasComment("主键");

                entity.Property(e => e.Goodbrand)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("goodbrand")
                    .HasComment("商品品牌");

                entity.Property(e => e.Goodname)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("goodname")
                    .HasComment("商品名称");

                entity.Property(e => e.Goodprice)
                    .HasColumnType("decimal(18, 2)")
                    .HasColumnName("goodprice")
                    .HasComment("商品价格");

                entity.Property(e => e.Goodtype)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("goodtype")
                    .HasComment("商品种类");
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.ToTable("user");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasComment("主键");

                entity.Property(e => e.Createtime)
                    .HasColumnType("datetime")
                    .HasColumnName("createtime")
                    .HasComment("创建时间");

                entity.Property(e => e.Password)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("password")
                    .HasComment("密码");

                entity.Property(e => e.Power)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("power")
                    .HasComment("权限");

                entity.Property(e => e.Realname)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("realname")
                    .HasComment("真实姓名");

                entity.Property(e => e.Updatetime)
                    .HasColumnType("datetime")
                    .HasColumnName("updatetime")
                    .HasComment("更新时间");

                entity.Property(e => e.Username)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("username")
                    .HasComment("用户名");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
